home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93b.txt / 000044_icon-group-sender _Tue Apr 27 02:15:01 1993.msg < prev    next >
Internet Message Format  |  1993-06-16  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Thu, 29 Apr 1993 12:08:29 MST
  2. Date: 27 Apr 93 02:15:01 GMT
  3. From: darwin.sura.net!wupost!usc!sdd.hp.com!cs.utexas.edu!uwm.edu!linac!uchinews!ellis!goer@gatech.edu  (Richard L. Goerwitz)
  4. Organization: University of Chicago
  5. Subject: Re: Is this passable code?
  6. Message-Id: <1993Apr27.021501.19198@midway.uchicago.edu>
  7. References: <9304260508.AA21290@internal.apple.com>
  8. Sender: icon-group-request@cs.arizona.edu
  9. To: icon-group@cs.arizona.edu
  10. Status: R
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12.  
  13. nevin@apple.com (Nevin ":-]" Liber) writes:
  14. >
  15. >procedure main(LArguments)
  16. >etc.
  17.  
  18.   every insert(SAnagrams, Permute(map(!LArguments)))
  19.  
  20. This shows precisely how Icon's control mechanisms ought to be used.
  21. !LArguments generates everything in the arg list.  Permute is also a
  22. generator.  The keyword "every" indicates that all possible results
  23. should be fetched, just as if this were Prolog :-).
  24.  
  25. >suspend sString[iPos := 1 to *sString] ||
  26. >        Permute(sString[1:iPos] || sString[iPos+1:0])
  27.  
  28. This is nice, too.  Uses "suspend" to trigger backtracking - which
  29. is then fed into the recursion to produce a full set of permutations.
  30.  
  31. Nevin:  Where did you learn your Icon?  Pretty idiomatic stuff.  You
  32. say it's 20 lines, but in fact most of that is whitespace or extra
  33. local declarations (e.g. local x local y = local x,y).  You did the
  34. important stuff in about 8 lines....
  35.  
  36. -- 
  37.  
  38.    -Richard L. Goerwitz              goer%midway@uchicago.bitnet
  39.    goer@midway.uchicago.edu          rutgers!oddjob!ellis!goer
  40.